define('framework/control/GillionPrecisionDirectiveConstructor', function () {
    return function () {
        return {
            restrict: 'A',
            link: function (scope, element, attrs) {
                var precisionCount = Number(attrs.gPrecision),
                    rounding = attrs.rounding !== 'false';
                element.on('blur', function () {
                    var $me = $(this),
                        value = $me.val(),
                        numberVal = Number(value),
                        fixedString, precision, i,decimals,roundNum;

                    if (!isNaN(numberVal) && !isNaN(precisionCount)) {
                        roundNum = Math.round(numberVal*Math.pow(10,precisionCount))/Math.pow(10,precisionCount);
                        fixedString = new String(roundNum);
                        decimals = fixedString.split('.')[1] || '';
                        if(decimals ==="" && precisionCount>0){
                            fixedString +=".";
                        }
                        for(i=decimals.length;i<precisionCount;i++){
                            fixedString +='0';
                        }
                        precision = value.split('.')[1] || '';
                        if (precision.length < precisionCount) {
                            $(this).val(fixedString);
                        } else if (precision.length > precisionCount) {
                            if (rounding === false) {
                                var after = precision.substr(precisionCount, 1);
                                if (Number(after) >= 5) {
                                    fixedString = fixedString.replace(/\d$/, Number(fixedString.charAt(fixedString.length - 1)) - 1)
                                }
                            }
                            $(this).val(fixedString);
                        }
                    }
                });
            }
        }
    }
});